package org.zhuxian.cn.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.zhuxian.cn.entity.Cultivation;
import org.zhuxian.cn.result.JsonResult;
import org.zhuxian.cn.service.CultivationService;

@RestController
@RequestMapping("/cultivation")
@Api(tags = "境界系统管理", description = "境界相关接口")
public class CultivationController {

    @Autowired
    private CultivationService cultivationService;

    @ApiOperation(value = "添加境界记录", notes = "添加新的境界系统记录")
    @PostMapping("/add")
    public JsonResult addCultivations(@ApiParam(value = "境界信息") @RequestBody Cultivation cultivation) {
        cultivationService.addCultivation(cultivation);
        return new JsonResult(200, "OK");
    }

    @ApiOperation(value = "更新境界记录", notes = "更新已存在的境界系统记录")
    @PostMapping("/update")
    public JsonResult updateCultivations(@ApiParam(value = "境界信息") @RequestBody Cultivation cultivation) {
        cultivationService.updateCultivation(cultivation);
        return new JsonResult(200, "OK");
    }

    @ApiOperation(value = "删除境界记录", notes = "删除指定的境界系统记录")
    @PostMapping("/delete")
    public JsonResult deleteCultivations(@ApiParam(value = "境界信息") @RequestBody Cultivation cultivation) {
        cultivationService.deleteCultivation(cultivation);
        return new JsonResult(200, "OK");
    }

    @ApiOperation(value = "获取所有境界记录", notes = "获取系统中所有的境界记录")
    @GetMapping("/all")
    public JsonResult getAllCultivations() {
        return new JsonResult(200, "OK", cultivationService.getAllCultivation());
    }
}